﻿Public Class frmDangKi 

    Private Sub frmDangKi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
        dt = TaiKhoanBUS.LoaiTaiKhoan()
        cbbLoaiTK.DataSource = dt
        cbbLoaiTK.DisplayMember = "TenLTK"
        cbbLoaiTK.ValueMember = "MaLTK"
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Close()
    End Sub

    Private Sub btnDangKi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangKi.Click
        If txtTenDN.Text = "" Then
            MessageBox.Show("Vui lòng điền tên tài khoản!")
            txtTenDN.Focus()
        Else
            If txtMatKhau.Text = "" Then
                MessageBox.Show("Vui lòng điền mật khẩu!")
                txtMatKhau.Focus()
            Else
                Dim tkDTO As New TaiKhoanDTO
                tkDTO.m_strTenDangNhap = txtTenDN.Text
                tkDTO.m_strMatKhau = txtMatKhau.Text
                tkDTO.m_strMaLoaiTK = cbbLoaiTK.SelectedValue.ToString()

                Dim a As Integer = TaiKhoanBUS.DangKiTK(tkDTO)
                If a = 1 Then
                    MessageBox.Show("Đăng kí thành công! Nhấn OK để đăng nhập.")
                    Close()
                Else
                    MessageBox.Show("Đăng kí thất bại!")
                    txtMatKhau.Text = ""
                    txtTenDN.Text = ""
                End If
            End If
        End If
    End Sub
End Class